<template>
  <div class="rightBodyContent">
    <div class="rightBodyContent-in">
      <div class="mb-10">
        <div class="toplineBox">
          <div class="toplineBox-left">
            <el-button size="small" @click="detailId=0,detailvisible=true" type="primary"><i class="el-icon-plus"></i>添加计算方式</el-button>
          </div>
          <p class="numberline toplineBox-right">总{{ page.total }}条</p>
        </div>
      </div>
      <!--本体列表，数据 -->
      <div class="table-body">
        <div class="table-body-box">
          <el-table
              ref="multipleTable"
              :data="arryList"
              :stripe="tableStyle.tableStripe"
              :border="tableStyle.tableBorder"
              tooltip-effect="dark"
              style="width: 100%"
              header-cell-class-name="table-text-c"
              cell-class-name="table-text-c"
          >
<!--            <el-table-column-->
<!--                prop="id"-->
<!--                label="序号" width="100">-->
<!--            </el-table-column>-->
            <el-table-column
                label="区角评价点"
                prop="title">
            </el-table-column>
            <el-table-column
                label="领域关联"
                prop="description">
              <template slot-scope="scope">
                <span
                    v-for="(item,index) in scope.row.domain_ids">{{ item.name }}{{ index !== scope.row.domain_ids.length - 1 ? '' : ',' }}</span>
              </template>
            </el-table-column>
            <el-table-column
                label="描述"
                prop="description">
            </el-table-column>
            <el-table-column
                label="操作"
                width="150">
              <template slot-scope="scope">
                <!--                <el-button size="small" @click="detelFn(scope.row.id,scope.$index)">详情</el-button>-->
                <el-button size="small" @click="detailId=scope.row.id,detailvisible=true">详情</el-button>
                <el-button type="danger" size="small" @click="detelFn(scope.row)" plain>删除</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <!--工具条 分页-->
      <el-col :span="24" class="toolbar">
        <el-pagination
            background
            layout="total, prev, pager, next"
            :total="page.total"
            :page-size="page.pagesize"
            @current-change="handleSizeChange">
        </el-pagination>
      </el-col>
    </div>
    <comDetail :visible.sync="detailvisible" :detailId="detailId"></comDetail>
  </div>
</template>

<script>
import {pagination, tableoption} from '@/utils/util.js'
import comDetail from "./detail";

export default {
  components: {
    comDetail
  },
  data() {
    return {
      addSegmentVisible: false,
      editId: '',
      arryList: [],
      handleSelection: [],
      // 设置table样式
      tableStyle: tableoption,
      // 设置table页面分页所需
      page: {
        pageindex: pagination.pageIndex,
        pagesize: pagination.pageSize,
        total: pagination.total
      },
      segmentId: 0,
      upgrade_id: 0,
      section_name: '',
      detailvisible: false,
      detailId: 0
    }
  },
  created() {
    this.InitFn()
  },
  methods: {
    // 初始化
    InitFn() {
      this.$fetch(this.api.corner.attr.index, {
        p: this.page.pageindex
      }).then((response) => {
        if (response.code === 0) {
          this.arryList = response.list.data
          this.page.total = response.list.total
        } else {
        }
      }).catch((err) => {
        console.log(err)
      })
    },
    // 分页
    handleSizeChange(val) {
      this.page.pageindex = val
      this.InitFn()
    },
    detelFn(row) {
      let self_ = this
      this.$confirm('确认删除此条数据？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        self_.$post(this.api.corner.attr.delete, {
          id: row.id
        }).then((response) => {
          if (response.code === 0) {
            self_.$message({
              message: '删除成功',
              type: 'success'
            })
            self_.InitFn()
          } else {
            self_.$message.error(response.msg)
          }
        }).catch((err) => {
          console.log(err)
        })
      }).catch(() => {

      })
    }
  },
  mounted() {
  }
}
</script>
